package com.lsj.core.constant.exception;

import lombok.Getter;

@Getter
public enum  ExceptionEnum {

    UNKNOWN_EXCEPTION(100, "未知异常"),

    ADD_ERROR(103, "添加失败"),

    UPDATE_ERROR(104, "更新失败"),

    DELETE_ERROR(105, "删除失败"),

    GET_ERROR(106, "查找失败");

    private Integer code;

    private String msg;

    ExceptionEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ExceptionEnum getByCode(int code){
        for (ExceptionEnum exceptionEnum : ExceptionEnum.values()) {
            if(code == exceptionEnum.code){
                return exceptionEnum;
            }
        }
        return null;
    }

}
